package com.xsm.ppsecret.ui;

import android.content.Intent;
import android.os.Handler;
import android.os.Message;
import android.os.Bundle;

import com.xsm.ppsecret.R;
import com.xsm.ppsecret.presenter.SplashPresenter;
import com.xsm.ppsecret.ui.implview.ISplashActivity;
import com.xsm.ppsecret.util.ShareManager;

public class SplashActivity extends BaseActivity implements ISplashActivity {

    private SplashPresenter mPresenter = new SplashPresenter(this);
    private Handler mHandler = new Handler() {
        @Override
        public void handleMessage(Message msg) {
            switch (msg.what) {
                case 1:
                    splashOver();
                    break;
            }
        }
    };

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_splash);
        mHandler.sendEmptyMessageDelayed(1, 2000);
    }

    @Override
    public void splashOver() {
        if (ShareManager.getInstance().isRegist()) {
            startActivity(new Intent(this, LoginActivity.class));
        } else {
            startActivity(new Intent(this, RegistActivity.class));
        }
        finish();
    }
}
